local Lua__FinalDIEND = fk.CreateSkill {
    name = "Lua__FinalDIEND",
    tags = {Skill.Permanent,Skill.Spirited,Skill.Compulsory}
}

Fk:loadTranslationTable{
  ["Lua__FinalDIEND"] = "神主DIEND",
  [":Lua__FinalDIEND"] = "持恒技，共鸣技，锁定技，该技能死亡后亦生效，昂扬技，昂扬条件：一名其他角色死亡时。效果：你获得其所有技能，当你技能数大于21时，你将Finalattack中的9改为21。且当你死亡时，若你技能数≤21，你将死亡改为休整一回合。",
  ["@@final_diend"] = "完全体DIEND",
  ["@@diendangyang"] = "神主 未昂扬",
}


Lua__FinalDIEND:addEffect(fk.EventAcquireSkill, {
    mute = true,
    can_trigger = function(self, event, target, player, data)
        return player:hasSkill(Lua__FinalDIEND.name,false,true)  and target == player and #player:getSkillNameList() > 21 and
        (player.general == "DIEND" or player.deputyGeneral == "DIEND") and player:getMark("@@final_diend") == 0
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        player:broadcastSkillInvoke("Lua__FinalDIEND", 1)
        room:notifySkillInvoked(player, Lua__FinalDIEND.name, "offensive")
        room:setPlayerMark(player, "@@final_diend", 1)
    end,
})

Lua__FinalDIEND:addEffect(fk.Death, {
    mute = true,
    can_trigger = function(self, event, target, player, data)
        if target == player  then
            return player:hasSkill(Lua__FinalDIEND.name,false,true) and #player:getSkillNameList() <= 21 and
            (player.general == "DIEND" or player.deputyGeneral == "DIEND")
        else
            return player:hasSkill(Lua__FinalDIEND.name,false,true) and
            (player.general == "DIEND" or player.deputyGeneral == "DIEND")
        end
    end,
    on_cost = function(self, event, target, player, data)
        -- 冷却技检查
        if target ~= player then
            local cooldown = player:getMark("@@diendangyang")
            if cooldown > 0 then
                -- 减少冷却值
                player.room:setPlayerMark(player, "@@diendangyang", 0)
                return false
            end
        end 
        return true
    end,
    on_use = function(self, event, target, player, data)
      local room = player.room
      if target == player then
        room:setPlayerRest(player, 1)
        room:notifySkillInvoked(player, Lua__FinalDIEND.name, "special")
      else
        player.room:setPlayerMark(player, "@@diendangyang", 1)
        room:handleAddLoseSkills(player, target:getSkillNameList(), nil, true, false)
        room:notifySkillInvoked(player, Lua__FinalDIEND.name, "special")
      end
    end,
})




return Lua__FinalDIEND 